import { MockMethod } from 'vite-plugin-mock'


export default [
  // 模拟文本上传API
  {
    url: '/api/text/upload',
    method: 'post',
     response: (req: any) => {
       const { content } = req.body;
        console.log('Mock接收到的文本内容:', content)
      
      // 模拟生成分享链接
      return {
        code: 200,
        message: '上传成功',
        data: {
          shareLink: `http://localhost:5173/share/text/${Date.now()}`
        }
      }
    }
  },
  
  // 模拟文件上传API
  {
    url: '/api/file/upload',
    method: 'post',
    response: (req: Request) => {
      // 模拟文件上传
      console.log('Mock接收到文件上传请求')
      
      // 模拟生成分享链接
      return {
        code: 200,
        message: '上传成功',
        data: {
          shareLink: `http://localhost:5173/share/file/${Date.now()}`
        }
      }
    }
  },
  
  // 模拟获取文本上传列表API
  {
    url: '/api/text/uploads',
    method: 'get',
    response: () => {
      // 模拟从服务器获取数据
      // 在实际场景中，这些数据可能来自数据库
      const mockData = [
        {
          id: '1',
          content: '示例文本1',
          shareLink: `http://localhost:5173/share/text/123456`,
          timestamp: Date.now() - 3600000
        },
        {
          id: '2',
          content: '示例文本2',
          shareLink: `http://localhost:5173/share/text/789012`,
          timestamp: Date.now() - 1800000
        }
      ]
      
      return {
        code: 200,
        message: '获取成功',
        data: mockData
      }
    }
  },
  
  // 模拟删除文本上传项API
  {
    url: '/api/text/upload/:id',
    method: 'delete',
    response: (req: any) => {
      const { id } = req.params
      console.log(`Mock删除ID为${id}的文本上传项`)
      
      return {
        code: 200,
        message: '删除成功',
        data: {
          id
        }
      }
    }
  }
] as MockMethod[]